-- @owner: songjing
-- @date: 2024-04-08
-- @testpoint: DML语句暂不支持spq多机执行流程

--step1:建表预置数据；expect：成功
drop table if exists t_spq_0043 cascade;
create table t_spq_0043(id int primary key, name varchar(10) not null, c_int int);

--step3:开启spq,dml执行计划;expect:查询成功,原生流程
set spqplugin.enable_spq = on;
--insert
explain analyze insert into t_spq_0043 values (1, 'aaa', 100), (2, 'bbb', 200), (3, 'ccc', 101), (4, 'ddd', 150), (5, 'eee', 222), (6, 'fff',500);
--upsert
explain analyze insert into t_spq_0043 values(1, 'upsert1', 202) on duplicate key update c_int = c_int +10;  --update
explain analyze insert into t_spq_0043 values(8, 'upsert8', 888) on duplicate key update c_int = c_int +10;  --insert
--update
explain analyze update t_spq_0043 set c_int= 1 where id > 2 and id < 60;
--delete
explain (analyze on, costs off) delete from t_spq_0043 where  c_int > any(select c_int from t_spq_0043);
-- select ... into
begin; /
explain analyze select * into t_spq_0043new from t_spq_0043;
rollback;
start transaction;
explain analyze with temp_tb as (select id from t_spq_0043) select * into t_spq_0043new from temp_tb as s1;
end;
select * from t_spq_0043new order by 1;

--step4:清理环境;expect:成功
drop table if exists t_spq_0043, t_spq_0043new cascade;
